<?php
/**
 * Created on 29 ���� 2014
 * Description: 
 * @author Aryeh Rein 
 */
include_once $_SERVER['DOCUMENT_ROOT'] . "/classes/Logger.php"; 

if(in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1','::1'))){
    Logger::warn("cannot send mail: localhost");
    echo "1";
    return;
};

$name = isset($_POST["name"]) ? $_POST["name"] : "";
$mail = isset($_POST["mail"]) ? $_POST["mail"] : "";
$phone = isset($_POST["phone"]) ? $_POST["phone"] : "";
// only 
//email parameters

$to = "michal@changeat.co.il, noa@gmail.com";

// To send HTML mail, the Content-type header must be set
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: <join@changeat.co.il>\r\n";
$subject = "בקשת הצטרפות";
$message = 
			"<div dir='rtl'>".
				"שלום<br/><br/>".
				"להלן פרטי בקשת הצטרפות:<br/><br/>".
				"<table border=1><tbody>".
					"<tr><td>שם:</td><td>$name</td></tr>".
					"<tr><td>אימייל:</td><td>$mail</td></tr>".
					"<tr><td>טלפון:</td><td>$phone</td></tr>".
				"</tbody></table>";
			
if(mail($to,$subject,$message,$headers)){
	echo "1";
} else {
	echo "0";
	Logger::error("failed sending mail: mail($to,$subject,$message,$headers)");
}